package com.atguigu.flink.chapter02_DataStreamAPI.multistream;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2022/10/22
 *
 *      并集。 将两个流合并到一个流中。
 *          S1<T>  union  S2<P>
 *              T 和 P 必须是一样的类型才能这样处理！
 *              同流，才能合污
 *                S3<T>
 */
public class Demo9_Union
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3, 4, 5);
        DataStreamSource<Integer> ds2 = env.fromElements(11, 12, 13, 14, 15);
        DataStreamSource<Integer> ds5 = env.fromElements(111, 121, 131, 141, 151);

        DataStreamSource<String> ds3 = env.fromElements("a", "b", "c");

        DataStream<Integer> ds4 = ds1.union(ds2,ds5);
        ds4.print();

        try {
                    env.execute();
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }
}
